using NodeCanvas.Variables;
using UnityEngine;

namespace NodeCanvas.Actions
{
	[Category("Movement")]
	[Description("Move & turn the agent based on input values provided ranging from -1 to 1. Per frame and in delta time")]
	[AgentType(typeof(Transform))]
	public class InputMove : ActionTask
	{
		[BlackboardOnly]
		public BBFloat strafe;

		[BlackboardOnly]
		public BBFloat turn;

		[BlackboardOnly]
		public BBFloat forward;

		public BBFloat moveSpeed = new BBFloat
		{
			value = 1f
		};

		public BBFloat rotationSpeed = new BBFloat
		{
			value = 1f
		};

		public bool repeat;

		protected override void OnExecute()
		{
			Move();
		}

		protected override void OnUpdate()
		{
			Move();
		}

		private void Move()
		{
			Quaternion b = base.agent.transform.rotation * Quaternion.Euler(Vector3.up * turn.value * 10f);
			base.agent.transform.rotation = Quaternion.Slerp(base.agent.transform.rotation, b, rotationSpeed.value * Time.deltaTime);
			Vector3 vector = base.agent.transform.forward * forward.value * moveSpeed.value * Time.deltaTime;
			Vector3 vector2 = base.agent.transform.right * strafe.value * moveSpeed.value * Time.deltaTime;
			base.agent.transform.position += vector2 + vector;
			if (!repeat)
			{
				EndAction();
			}
		}
	}
}
